<div id="maincontent">
	<div id="content">
    <div class="box1">
      <h1><?php echo lico_lang('general', 'editprofile.page.title'); ?></h1>
        <div class="description"><?php echo lico_lang('general', 'editprofile.page.description'); ?></div>
      
      
<?php

  $select = "SELECT *, UNIX_TIMESTAMP(f_ctime), UNIX_TIMESTAMP(f_mtime) FROM `users` WHERE `f_key`='".lico_ESC($_SESSION['userid'])."'";
  $seluser = $db->unbuffered_query_first($select);
  if (isset($seluser[0]) && intval($seluser[0]) >= 1) {
    //  f_key 	f_raw 	f_clean 	f_ctime 	f_mtime 	email 	login 	state 	privacy 	credentials 	logintime 	emailtime 	lang
    $f_key = intval($seluser[0]);
    $myregtime = date("Y/m/d, h:ia", intval($seluser[15]));
    $mylastchangetime = date("Y/m/d, h:ia", intval($seluser[16]));
    $myemail = trim($seluser[5]);
    $myoldcounternum = intval($seluser[13]);
    $publishemail = trim($seluser[8]);
    $openid = trim($seluser[14]);
    $myusername = trim($seluser[15]);
  }
  $select = "SELECT *, UNIX_TIMESTAMP(f_ctime), UNIX_TIMESTAMP(f_mtime) FROM `persons` WHERE `f_key`='".lico_ESC($_SESSION['userid'])."'";
  $seluser = $db->unbuffered_query_first($select);
  if (isset($seluser[0]) && intval($seluser[0]) >= 1) {
    //  f_key 	f_raw 	f_clean 	f_ctime 	f_mtime 	name 	placeid 	placesource 	city 	state 	country 	email 	homepage 	ident 	may_publish 	method 	started 	usage
    $myname = trim($seluser[5]);
    $placeid = trim($seluser[6]);
    $placesource = trim($seluser[7]);
    $mycity = trim($seluser[8]);
    $mystate = trim($seluser[9]);
    $mycountry = trim($seluser[10]);
    $myhomepage = trim($seluser[12]);
    $publishinfo = trim($seluser[14]);
    $started = trim($seluser[16]);
    $usages = trim($seluser[17]);
    if (trim($started) != "") {
      $tmp = explode(" ", $started);
      $started_month = $tmp[0];
      $started_year = $tmp[1];
    }
    $usage = array();
    if (trim($usages) != "" && preg_match("`, `", $usages)) {
      $usage = explode(", ", $usages);
    } else {
      $usage[] = trim($usages);
    }
  }
  $out .= "     <form name=\"setprofile\" action=\"/success.html\" method=\"post\">\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'myusername').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[myusername]\" value=\"".html_entity_decode(trim($myusername))."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'myname').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[myname]\" value=\"".html_entity_decode(trim($myname))."\"/></span>\n";
  $out .= "       </div>\n";
#  $out .= "       <div class=\"formitem even\">\n";
#  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'openid').":</label>\n";
#  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[openid]\" value=\"".html_entity_decode(trim($openid))."\"/></span>\n";
#  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'myemail').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[myemail]\" value=\"".trim($myemail)."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'myhomepage').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[myhomepage]\" value=\"".trim($myhomepage)."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mycity').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[mycity]\" value=\"".html_entity_decode(trim($mycity))."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mystate').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[mystate]\" value=\"".html_entity_decode(trim($mystate))."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mycountry').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[mycountry]\" size=\"3\" maxlength=\"2\" value=\"".html_entity_decode(trim($mycountry))."\"/></span>\n";
  $out .= "       </div>\n";
  
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'started').":</label>\n";
  $out .= "         <span class=\"forminput\">\n";
  $out .= "           <select class=\"month\" name=\"lico[started_month]\">\n";
  $out .= "             <option value=\"\"> </option>\n";
  for ($i=0; $i<12; $i++) {
    $month = $lico['months'][$i];
    if ($month == trim($started_month)) {
      $out .= "             <option value=\"".$month."\" selected=\"selected\">".lico_lang('profile', 'month.'.$month)."</option>\n";
    } else {
      $out .= "             <option value=\"".$month."\">".lico_lang('profile', 'month.'.$month)."</option>\n";
    }
  }
  $out .= "           </select> &nbsp;\n";
  $out .= "           <select class=\"year\" name=\"lico[started_year]\">\n";
  $out .= "             <option value=\"\"> </option>\n";
  for ($i=date("Y", time()); $i>1990 ; $i--) {
    if ($i == intval($started_year)) {
      $out .= "             <option value=\"".$i."\" selected=\"selected\">".$i."</option>\n";
    } else {
      $out .= "             <option value=\"".$i."\">".$i."</option>\n";
    }
  }
  $out .= "           </select>\n";
  $out .= "         </span>\n";
  $out .= "       </div>\n";
  
  
  
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'usage').":</label>\n";
  $out .= "         <span class=\"forminput\">\n";
  $out .= "           <select class=\"multiple\" name=\"lico[usage][]\" multiple=\"multiple\">\n";
  $out .= "             <option value=\"\"> </option>\n";
  for ($i=0; $i<count($lico['usages']); $i++) {
    $thisusage = $lico['usages'][$i];
    if (in_array($thisusage, $usage)) {
      $out .= "             <option value=\"".$lico['usages'][$i]."\" selected=\"selected\">".lico_lang('profile', 'usage.'.$lico['usages'][$i])."</option>\n";
    } else {
      $out .= "             <option value=\"".$lico['usages'][$i]."\">".lico_lang('profile', 'usage.'.$lico['usages'][$i])."</option>\n";
    }
  }
  $out .= "           </select>\n";
  $out .= "         </span>\n";
  $out .= "       </div>\n";
  
  
  
  
  
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'may.publish.email').":</label>\n";
  $out .= "         <span class=\"forminput\"><select name=\"lico[publishemail]\"><option value=\"NO\"".($publishemail=="NO"?" selected=\"selected\"":"").">NO</option><option value=\"YES\"".($publishemail=="YES"?" selected=\"selected\"":"").">YES</option></select></span>\n";
  $out .= "       </div>\n";
  
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'may.publish.info').":</label>\n";
  $out .= "         <span class=\"forminput\"><select name=\"lico[publishinfo]\"><option value=\"NO\"".($publishinfo=="NO"?" selected=\"selected\"":"").">NO</option><option value=\"YES\"".($publishinfo=="YES"?" selected=\"selected\"":"").">YES</option></select></span>\n";
  $out .= "       </div>\n";
    
  $out .= "       <div class=\"formsubmit formitem\">\n";
  $out .= "         <input type=\"hidden\" name=\"lico[action]\" value=\"setprofile\"/>\n";
  $out .= "         <span class=\"formsubmit-button\"><input type=\"submit\" name=\"lico[submit]\" value=\"".lico_lang('profile', 'save.data')."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "     </form>\n";
  echo $out;



?>
      
      
    </div>
  </div>
</div>
